package deom1;

import java.util.PriorityQueue;

public class PriorityQueueTest {
    public static void main(String[] args) {

    }

}
class Solution {
    public int halveArray(int[] nums) {
        PriorityQueue<Double> du = new PriorityQueue<>((a, b) -> b.compareTo(a));
        double sum = 0.0;
        for (int x : nums) {
            du.offer((double) x);
            sum += x;
        }
        sum /= 2;
        int count = 0;
        while (sum > 0) {
            double ret = du.poll() / 2;
            sum -= ret;
            count++;
            du.offer(ret);
        }
        return count;
    }
}